Skip to content

[codex] Preserve PR materialization failure chains#3443

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/preserve-pr-materialization-fallback-causes
Jun 20, 2026
Merged

[codex] Preserve PR materialization failure chains#3443
juliusmarminge merged 1 commit into
mainfrom
codex/preserve-pr-materialization-fallback-causes

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • add a structured pull-request materialization error with repository and branch correlation fields
  • preserve both the repository-head failure and pull-request-ref fallback failure in one AggregateError cause chain
  • cover the dual-failure path through GitManager behavior

Testing

  • vp test apps/server/src/git/GitManager.test.ts (59 passed)
  • vp check
  • vp run typecheck

Note

Low Risk
Scoped to PR thread preparation error reporting and contracts; behavior on success is unchanged, with clearer failure diagnostics on dual-fetch errors.

Overview
When preparing a PR worktree thread, both the repository-head fetch and the pull-request-ref fallback can fail; callers now get a single GitPullRequestMaterializationError instead of only the fallback GitCommandError.

The new contract error carries cwd, PR number, head repo/branch, and local branch name, with an AggregateError cause that lists both underlying git failures (primary as cause.cause). GitManagerServiceError includes this type so UI/RPC can pattern-match it.

Related logging in upstream configuration and setup-script failures is switched to structured Effect.logWarning payloads rather than interpolated strings.

Reviewed by Cursor Bugbot for commit 4734fe1. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Preserve both branch materialization failures in GitPullRequestMaterializationError

  • Adds GitPullRequestMaterializationError to packages/contracts/src/git.ts, a structured error carrying cwd, pullRequestNumber, headRepository, headBranch, localBranch, and a cause field.
  • When both the primary head branch fetch and the fallback fetchPullRequestBranch fail in materializePullRequestHeadBranch, the error now wraps both failures in an AggregateError (with primaryCause as its own cause) rather than surfacing only the fallback error.
  • Replaces string-interpolated warning logs with structured Effect.logWarning calls in configurePullRequestHeadUpstream and preparePullRequestThread.
  • Adds a test in apps/server/src/git/GitManager.test.ts asserting that both GitCommandError instances are preserved in the AggregateError cause chain.
  • Behavioral Change: GitManagerServiceError now includes GitPullRequestMaterializationError; consumers that pattern-match this union need to handle the new variant.

Macroscope summarized 4734fe1.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7cda890b-a7a2-4ab8-8142-0cbd5c89e3e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/preserve-pr-materialization-fallback-causes

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR improves error handling by preserving both failure causes when PR branch materialization fails. The changes are limited to error paths with a new additive error type and corresponding test coverage - a straightforward, low-risk improvement.

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/preserve-pr-materialization-fallback-causes branch from 4b64df7 to 4734fe1 Compare June 20, 2026 23:31
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 23:31

Dismissing prior approval to re-evaluate 4734fe1

@juliusmarminge
juliusmarminge merged commit 5edf7c5 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/preserve-pr-materialization-fallback-causes branch June 20, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant